package com.zhou.jianzhi.controller.web;/**
 * @project jianzhi-server-master
 * @description
 * @author 黄嘉杰
 * @date 2025/1/23 11:32:10
 * @version 1.0
 */

import com.zhou.jianzhi.common.AjaxResult;
import com.zhou.jianzhi.entity.po.ForumReply;
import com.zhou.jianzhi.service.ForumReplyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @description: TODO
 * @author 黄嘉杰
 * @date 2025/1/23 11:32
 * @version 1.0
 */
@RestController
@RequestMapping("/forum/reply")
public class ReplyController {

    @Autowired
    private ForumReplyService replyService;

    /**
     * 获取帖子的回复列表
     */
    @GetMapping("/list/{postId}")
    public AjaxResult getReplyList(
            @PathVariable Long postId,
            @RequestParam(defaultValue = "1") Integer page,
            @RequestParam(defaultValue = "10") Integer size
    ) {
        return AjaxResult.success(replyService.getReplyList(postId, page, size));
    }

    /**
     * 发表回复
     */
    @PostMapping("/add")
    public AjaxResult addReply(@RequestBody ForumReply reply) {
        replyService.addReply(reply);
        return AjaxResult.success();
    }

    /**
     * 删除回复
     */
    @DeleteMapping("/{id}")
    public AjaxResult deleteReply(@PathVariable Long id) {
        replyService.deleteReply(id);
        return AjaxResult.success();
    }
}
